﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using WGLGridView;
using DBAccessor.Accessor;
using AlanUtilities;
using DBList.Entities;
using DBList;
using System.Collections.Generic;

public partial class LJTotalTJDetail : System.Web.UI.Page
{
	protected void Page_Load(object sender, EventArgs e)
	{
		String strUID = OperateControl.PickupAvaiableUserID(this);
		if (!IsPostBack)
		{
			int nUID;
			int.TryParse(strUID, out nUID);
			MemberAccessor memberSystem = new MemberAccessor();
			UserData usrData = memberSystem.GetMemberInfo(nUID);
			if (usrData.GroupId != 1 && usrData.GroupId != 2)
			{
				Session[@"LogUserId"] = null;
				OperateControl.PickupAvaiableUserID(this);
				return;
			}
			string strKindID = Request.QueryString.Get("ArticleId");
			if (strKindID == null)
			{
				Session[@"LogUserId"] = null;
				OperateControl.PickupAvaiableUserID(this);
				return;
			}
			operaterLabel.Text = strKindID;

			BindGrideView();
		}
	}
	private void ShowEmptyRecord()
	{
		string[] fields = { "Introduction", "KindName", "SingleMoney", "TotalNumber", "TMCurrency", "UsedNumber", "UMCurrency"};
		WGLGridView.WGLGridView.ClearAndShowEmptyGridView(GridView1, fields);
	}
	protected void AspNetPager1_PageChanged(object sender, EventArgs e)
	{
		BindGrideView();
	}
	protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		if (e.Row.RowType == DataControlRowType.DataRow)
		{
			e.Row.Attributes.Add("onclick", "GridView_selectRow(this)");
			e.Row.Height = 25;
		}
		else if (e.Row.RowType == DataControlRowType.Header)
		{
			e.Row.Height = 25;
		}
	}
	protected void btnSearch_Click(object sender, EventArgs e)
	{
		AspNetPager1.CurrentPageIndex = 1;
		BindGrideView();
	}
	private void BindGrideView()
	{
		string strKindID = operaterLabel.Text.Trim();
		int nKindID = 0;
		int.TryParse(strKindID, out nKindID);
		if (nKindID == 0)	return;
		string strmdMatch = tbMDMatch.Text.Trim();

		int noutTotal = 0;
		CPNAccessor pnaAcce = new CPNAccessor();
		List<LJTJItemData> listData = pnaAcce.LJTotalTJDetail(nKindID, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out noutTotal, strmdMatch);
		GridView1.DataSource = listData;
		if (listData.Count == 0)
		{
			ShowEmptyRecord();
		}
		else
		{
			GridView1.DataBind();
		}
		recLabel.Text = @"总记录：";
		recLabel.Text += noutTotal.ToString();
		recLabel.Text += @" 条";
	}
}
